﻿using Abp.Application.Services.Dto;
using Batman.Cms.Core.Controllers;
using Batman.Cms.Core.Models.Mvc;
using Batman.Jianbei.Forum.Areas.Forum.Filters;
using Batman.Jianbei.Forum.Core.Domains.Posts;
using Batman.Jianbei.Forum.Services.Posts;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace Batman.Jianbei.Forum.Areas.Forum
{
    [Authorize]
    [Area("Forum")]
    public class CommentController : BatmanController<PostComment>
    {
        public CommentService CommentService { get; set; }

        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public IActionResult Post(CommentPostInput model)
        {
            string wxUID = User.GetWxUserId();

            var result = CommentService.AddPostComment(model, wxUID);

            return Json(result);
        }

        /// <summary>
        /// 获取评论详细
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        public IActionResult Detail(string commentId)
        {
            var result = CommentService.GetComment(commentId);

            return Json(result);
        }

        /// <summary>
        /// 获取回复
        /// </summary>
        /// <param name="page"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public IActionResult Replies(PagedResultRequestDto page, ReplyFilter filter)
        {
            var result = CommentService.GetReplies(page, filter);

            return Json(result);
        }

        /// <summary>
        /// 我的评论（我发出的评论）
        /// </summary>
        /// <returns></returns>
        public IActionResult MyComments(List<string> commentIdsExcluded)
        {
            var resutl = CommentService.GetMyComments(User.GetWxUserId(), commentIdsExcluded);
            return Json(resutl);
        }
    }
}
